<template>
    <a-spin :spinning="spinning">
        <BTable :columns="columns" :data="dataRows"></BTable>
    </a-spin>
    
</template>

<script lang='ts' setup>
import { parseTime } from '@/utils'
import { ref } from 'vue'
import { testDataApi } from '@/api/WaterTest'

    const props = defineProps<{
        id : number;
    }>()


    const columns = ref<Column[]>([
        {
            title : '光照值',
            dataIndex : 'lux',
            align : 'center',
        },
        {
            title : '时间',
            dataIndex : 'time',
            align : 'center',
            customRender({record}) {
                return parseTime(record.time)
            },
        },
    ])

    const dataRows = ref<any[]>([])
    const spinning = ref(true)





    testDataApi(props.id).then(r => {
        if(r.data) {
            r.data.forEach(item => {
                dataRows.value.push(JSON.parse(item))
            })
            //dataRows.value = r.data
        }

        spinning.value = false
    })

</script>